package br.eng.megaprojetos.view;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.zkoss.zk.ui.Component;

import br.com.vexillum.util.ReflectionUtils;
import br.com.vexillum.util.SpringFactory;
import br.eng.megaprojetos.control.FunctionaryController;
import br.eng.megaprojetos.control.StateController;
import br.eng.megaprojetos.model.Functionary;
import br.eng.megaprojetos.model.State;

@SuppressWarnings("serial")
@org.springframework.stereotype.Component
@Scope("prototype")
public class FunctionaryComposer extends BasePersonComposer<Functionary, FunctionaryController> {

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		loadBinder();
	}
	
	@Override
	protected String getUpdatePage() {
		return null;
	}

	@Override
	protected String getDeactivationMessage() {
		return null;
	}

	@Override
	public FunctionaryController getControl() {
		return SpringFactory.getController("functionaryController", FunctionaryController.class, ReflectionUtils.prepareDataForPersistence(thisComposer));
	}

	@Override
	public Functionary getEntityObject() {
		return new Functionary();
	}
	
	@SuppressWarnings("unchecked")
	public List<State> getStates(){
		return (List<State>) SpringFactory.getController("stateController", StateController.class, null).doAction("listAll").getList();
	}

}
